package com.gitee.faster.webdav.kernel.model;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import jakarta.xml.bind.annotation.*;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @author hongda.li
 */
@Data
@Accessors(chain = true)
@SuppressWarnings("SpellCheckingInspection")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
        "content"
})
@XmlRootElement(name = "getlastmodified")
public class GetLastModified {

    @XmlMixed
    private List<String> content;

    public static GetLastModified byDate(Date date) {
        GetLastModified modified = new GetLastModified();
        modified.setContent(Collections.singletonList(DateUtil.format(date, DatePattern.HTTP_DATETIME_FORMAT)));
        return modified;
    }
}
